<?php    
	$id= request('id',false,true);
	if(empty($id))return false;
	
	//根据会员id查询记录，总管理查看全部记录
	$admin_obj = new admin();
	$info = $admin_obj->out_cookie();
	if(empty($info))exit('请先登录');
	
	$time=request('time');
	$data=false;
	if($time){
		$data['time']=$time;
		$timestr=strtotime($time);
	}else{
		$timestr=time();
	}
		
	$object=new zhg();
	$result = $object->info($id);
    if(empty($result))exit('项目不存在');
		
	if(6!=$info['group'] && $info['id']!=$result['uid'])exit('您的权限不足，无法访问');
	
	$res=$object->total($id,$data);		
	$icon_type=array(1=>'挖机计数',3=>'渣车');
	$coord_first='108.95,34.27';
	
	$list=$res['list'];
	$list_group=$res['list_type'];
	$list_wj=$list_group[1];
	$list_zc=$list_group[3];
	$_num=0;
	if($list){
		$coord_first=$list[0]['coord_x'].','.$list[0]['coord_y'];
		$_num=count($list);
	}
	
	//分别统计  挖机
	$list_wj_sum=0;
	$list_wj_num=0;
	if($list_wj){	
		$list_wj_num=count($list_wj);		
		foreach($list_wj as $vo)$list_wj_sum+=$vo['num'];
	}
	
	//渣车
	$list_zc_sum=0;
	$list_zc_num=0;
	if($list_zc){
		$list_zc_num=count($list_zc);
		foreach($list_zc as $vo)$list_zc_sum+=$vo['num'];
	}	
	
	
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script language="JavaScript" charset="utf-8" type="text/javascript" src="/static/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=6URYl63zG23FuMDicG1mhUUG1Gm6pKuC"></script>
<script type="text/javascript" src="/static/my97/wdatepicker.js"></script>
<script type="text/javascript" src="/static/artDialog/jquery.artDialog.js?skin=default"></script>
<title>工地指挥官_顺运通工程管理系统</title>
<style type="text/css">
body,html{width:100%;height:100%;margin:0;font-family:"微软雅黑"}
#allmap{width:100%;height:100%}
p{margin-left:5px;font-size:14px}
.logo{float:left}
.logo img{width:auto !important;height:20px !important}
.record{width:100%}
.record td{padding:2px;font-size:12px;line-height:25px;color:#333}
.record th{font-weight:bolder;line-height:30px;font-size:14px;color:#000}
.arrow{padding:10px !important;box-shadow:0 1px 3px rgba(0,0,0,0.4);background-color:#fff !important;border-radius:5px;background-repeat:no-repeat !important;background-position:4px 9px !important}
.arrow:first-letter{padding-right:10px;color:#fff}
.arrow.hover{animation-name:fadeinleft2;animation-duration:0.5s;animation-iteration-count:infinite}
@-webkit-keyframes fadeinleft2{0%{background-color:#fff}49%{background-color:#dfdfdf}100%{background-color:#fff}}
.record tr:nth-child(even){background:#f2f2f2}
.shuoming{font-size:16px;text-align:center;padding:2px 0;color:#ffffff;background:#684035;position:absolute;width:100%;z-index:9999}
.shuoming select{padding:5px 10px;border-radius:3px;border:0;color:#666px}
.shuoming img{width:15px;vertical-align:middle}
.arrow{background-repeat:no-repeat;padding-left:9px}
.shuoming p{font-size:16px;margin-top:3px;margin:0;padding:0;margin-top:4px}
.animated-card{width:0;height:384px;position:fixed;left:20px;top:100px;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,0.4);border-radius:5px;overflow:hidden}
.animated-card .animated-card_top{padding:10px;background-color:#efefef;font-size:16px;color:#333;text-align:left}
.animated-card .animated-card_box{padding:10px}
.animated-card .animated-card_box ul{width:100%;margin:0;padding:0;overflow:auto;height:308px}
.animated-card .animated-card_box ul li{width:100%;border-bottom:1px solid #dfdfdf;list-style:none;padding:8px 0;color:#333;text-align:left;float:left}
.animated-card .animated-card_box ul li .pic{width:87px;height:66px;background-color:#333;float:left}
.animated-card .animated-card_box ul li .pic img{width:100%;height:100%}
.animated-card .animated-card_box ul li .info{width:140px;margin-right:10px;float:right}
.animated-card .animated-card_box ul li .info h3{font-size:16px;line-height:25px;margin:0}
.animated-card .animated-card_box ul li .info p{font-size:12px;color:#666}
.full{display:block;width:20px;height:20px;float:right;background-repeat:no-repeat;margin-left:10px}
.fullok{background-image:url(/static/images/full.png);background-size:20px 20px;margin-top:5px}
.fullcancel{background-image:url(/static/images/cancel.png);background-size:15px 15px;margin-top:7px}
.close{float:right;text-decoration:none;color:#000000}
li,dd{list-style-type:none;margin:0px;padding:0px}
.ulist{position:absolute;right:0px;top:0;background-color:rgba(255,255,255,0.90);padding:5px;border:1px solid #dfdfdf;height:390px;overflow:auto;height:98.7%}
.ulist ul{margin:0;padding:0;margin-top:30px}
.ulist li{padding:5px 0;border-bottom:1px solid #dfdfdf;margin-bottom:5px}
.ulist li img{width:30px;height:30px;vertical-align:middle}
.ulist li p{display:inline-block;text-align:center;margin:0;padding:0 8px}
.ulist li input{vertical-align:middle}
	
/*王一帆修改  19-6-19  挖机地图*/
.ulist {padding: 5px 10px;}
.ulist li p {display: block;text-align: left;margin: 0;padding:0px 40px 7px 0px;font-size: 16px;color: #000;}	
.ulist li span {float:right;font-size:14px;color:#ff0000;font-weight:bold;}
.ulist li {font-size: 14px;color: #7f7f7f;}

/*王一帆修改 16-6-21  挖机地图*/	
.ulist {padding: 5px 10px;margin-top: 34px;position: fixed;height: 95.5%;overflow:scroll;}
.ulist div{padding: 1% 0;    border-radius: 5px;}
.ulist div p{    color: #76ad43;font-weight: bold;}
.ulist ul {margin-top: 15px;}
::-webkit-scrollbar{width:14px;}
::-webkit-scrollbar-track{background-color:#54423d;}
::-webkit-scrollbar-thumb{background-color:#54423d;}
::-webkit-scrollbar-thumb:hover {background-color:#54423d;}
::-webkit-scrollbar-thumb:active {background-color:#54423d;}
.ulist li p {padding: 0px 0px 7px 0px;}

/*王一帆修改 16-6-24  挖机地图*/	
.ulist {background-color: #54423d;}
.ulist li p {color: #fff;}
.ulist li {color: #b9b9b9;border-bottom: 1px solid rgb(113, 93, 88);border-top: 1px solid rgb(113, 93, 88);margin: -1px 0px;padding: 8% 15%;width: 97%;}
.ulist li span {color: #f5cf71;}
.ulist div {width: 111px;margin-left: -10px;}
.ulist ul {margin-left: -17px;width: 100%;float: left;}

</style>
</head>
<body>
<div class="shuoming">


<div style="width:96%; margin:0 auto;">

<div class="logo" style="font-weight: bold;font-size: 18px;"><?php echo $result['title'];?></div>
<p style="float:right; ">
 记录时间：<font id="ontime" style="margin-right:10px;color:#7fff00;cursor: pointer;"><?php echo date('Y-m-d H:i',$timestr);?></font>
 共计：<font style="color:#7fff00;" id="total"><?php echo $_num; ?></font>&nbsp;台设备
<a href="javascript:switchfullscreen();" id="afull" class="full fullcancel"></a>
</p>


</div></div>


	<div id="allmap"></div>

    <div id="ulist">
       <div class="ulist" style="left:0px;width:115px;margin-left: -1px; padding-left: 1.5%;">
          <div>
             <p>设备总数：<?php echo $list_zc_num;?></p>
             <p>记录总数：<?php echo $list_zc_sum;?></p>
          </div>
          <ul>
             <?php
               if($list_zc){
                 foreach($list_zc as $vo){
             ?>
             <li>              
              <p><?php echo $icon_type[$vo['type']];?></p>
              <?php echo $vo['dname'];?>   <span><?php echo $vo['num'];?></span>
             </li>          
             <?php }} ?>  
          </ul>
       </div>    
    
       <div class="ulist" style="right:0px;width:115px; margin-right: 1px;padding-left: 1.5%;">
          <div>
             <p>设备总数：<?php echo $list_wj_num;?></p>
             <p>记录总数：<?php echo $list_wj_sum;?></p>
          </div>       
          <ul>
             <?php
               if($list_wj){
                 foreach($list_wj as $vo){
             ?>
             <li>              
              <p><?php echo $icon_type[$vo['type']];?></p>
              <?php echo $vo['dname'];?>   <span><?php echo $vo['num'];?></span>
             </li>          
             <?php }} ?>  
          </ul>
       </div>
    </div>

    <div id="msgbar" style="display:none;">
       <input type="text" name="time" id="newtime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" class="input-text Wdate" size="20" value="<?php echo date('Y-m-d H:i',$timestr);?>" readonly>
    </div>
    
</body>
</html>
<script type="text/javascript">

$(function(){
	$("#ontime").click(function(){

		art.dialog({
		    lock: true,		   
		    opacity: 0.57,	// 透明度
		    title:'选择数据时间',
		    content: document.getElementById('msgbar'),	
		    ok: function () {		        
		        location.href="/admin/admin_project_map_full?id=<?php echo $id;?>&time="+$("#newtime").val();	        
		    },		   
		    cancel: true
		});
		
         
	});

<?php if($_num<1){ ?>
art.dialog({
    lock: true,		   
    opacity: 0.57,	// 透明度	
    icon: 'error',
    content: '今天还没有数据哦！',
    cancel: true 	        
});
<?php } ?>

	
})


    function fullscreen() {
        element = document.documentElement;
        if(element.requestFullScreen) {
            element.requestFullScreen();
        }
        else if(element.webkitRequestFullScreen ) {
            element.webkitRequestFullScreen();
        }
        else if(element.mozRequestFullScreen) {
            element.mozRequestFullScreen();
        }
    }

    function exitFullscreen() {
        if(document.exitFullscreen) {
            document.exitFullscreen();
        }
        else if(document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        }
        else if(document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        }
    }

    var isfullscreen = false;
    function switchfullscreen(){
		if(isfullscreen){
            exitFullscreen();
            $("#afull").addClass("fullcancel");
            $("#afull").removeClass("fullok");
            isfullscreen = false;
		}
		else{
            fullscreen();
            $("#afull").addClass("fullok");
            $("#afull").removeClass("fullcancel");
            isfullscreen = true;
		}
	}


    function refresh(){ 
        location.href="/admin/admin_project_map_full?id=<?php echo $id;?>";
        /**     
    	$.getJSON('/handle.php?h=zhg/freshCoord&pid=<?php echo $id;?>',function(res){
    		map.clearOverlays(); 
    		if(res.info){		    			
    			var data_info=res.info;
    			for(var i=0;i<data_info.length;i++){
    				var json=data_info[i];				
    				var point = new BMap.Point(json.coord_x,json.coord_y);
    				addMarker(point,json);	
    			}
    			$("#ontime").html(res.time);
    			$("#total").html(res.num);
    			setTimeout(refresh,900000);
    		}
    	})
    	**/
    }


    
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	var point = new BMap.Point(<?php echo $coord_first;?>);
	map.centerAndZoom(point,17);
	map.enableScrollWheelZoom();
	 // 添加带有定位的导航控件
	  var navigationControl = new BMap.NavigationControl({
	    // 靠左上角位置
	    anchor: BMAP_ANCHOR_TOP_LEFT,
	    // LARGE类型
	    type: BMAP_NAVIGATION_CONTROL_LARGE,
	    // 启用显示定位
	    enableGeolocation: true
	  });


	  var opts = {
			  width : 350,     // 信息窗口宽度
			  height: 160,     // 信息窗口高度
	}
    var convertor = new BMap.Convertor();

		// 编写自定义函数,创建标注
		function addMarker(point,json){
			var name=json.doper;
			var dname=json.dname;
			var phone=json.dophone;
			var num=json.num;
			var img='/static/img/kache.png';//json.uinfo.head;
			var time=json.ctime;//json.time;
			var type=json.type ;//json.uinfo.type;
			if(type<3)img='/static/img/wj.png';
			var typestr='';
			if(1==type){
              typestr='挖机计数';
			}else if(2==type){
			  typestr='挖机计时';
		    }else{
		      typestr='渣车';
			}


			var myIcon = new BMap.Icon(img,new BMap.Size(30,20));
			var marker = new BMap.Marker(point,{icon:myIcon});  // 创建标注
		    
		    map.addOverlay(marker);
			var label = new BMap.Label(name+' '+dname,{offset:new BMap.Size(20,-10)});
			marker.setLabel(label);

			var sContent = "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>"+name+" ( "+typestr+" )</h4>";
		        opts.width=100;
		        opts.height=100;				   
				if(phone)sContent=sContent+"<p style='margin:0;line-height:1.5;font-size:13px;'>联系电话："+phone+"</p>";
				sContent=sContent+"<p style='margin:0;line-height:1.5;font-size:13px;'>设备编号："+dname+"</p>";
				sContent=sContent+"<p style='margin:0;line-height:1.5;font-size:13px;'>记录时间："+time+"</p>";
				sContent=sContent+"<p style='margin:0;line-height:1.5;font-size:13px;'>上传数据："+num+"</p>";
				sContent=sContent+"</div>";
				
				var infoWindow = new BMap.InfoWindow(sContent,opts);  // 创建信息窗口对象
				marker.addEventListener("click", function(){
					map.openInfoWindow(infoWindow,point); //开启信息窗口
				});
				
	  }


	    <?php if($_num>0){  ?>	  
		var coordsay=<?php echo json_encode($list); ?>;
		
	    function createPoint(res){
	    	map.clearOverlays(); 
			var data_info=res;
			for(var i=0;i<data_info.length;i++){
				var json=data_info[i];				
				var point = new BMap.Point(json.coord_x,json.coord_y);
				addMarker(point,json);	
			}
	    }

	    createPoint(coordsay);
       
	    setTimeout(refresh,900000);	    
	    <?php }?>   
</script>




